//
// UdpSocket.h
//
// $Id: //base/include/UdpSocket.h
//
// Library: base
// Package: UdpSocket
// Module:  UdpSocket
//
// Definition of the UdpSocket class.
//
// Copyright (c) 2012-2012, iGuard.
// doitsjz@163.com	jelin
//


#ifndef UDPSOCKET_INCLUDED
#define UDPSOCKET_INCLUDED

#include <pjlib.h>

#include "BaseSocket.h"



/**
	simply udp client and server
*/
class Proactor;
class BASE_API UdpSocket: public BaseSocket
{
public:
//	UdpSocket(Proactor* proactor,pj_sock_t newsock);
	UdpSocket(Proactor* proactor,char* ip=NULL,unsigned short port=0);
	virtual ~UdpSocket();

public:
	int SendTo(const char* buff,long& size,const pj_sockaddr_t *addr,
				int addr_len,int flags=0);
	
	int SendTo(const char* buff,long& size,char* ip,
				unsigned short port,int flags=0);

	int RecvFrom(long size,int flags=0);

public:
	virtual pj_bool_t OnDataRecvFrom(void *data,pj_size_t size,
			const pj_sockaddr_t *src_addr,int addr_len,int status);
	virtual pj_bool_t OnDataSend(pj_ioqueue_op_key_t *send_key,int sendsize);
};


#endif